package net.sx.minemodule.mvp.activities;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.homegoods.aroutercomment.ARouterPath;
import com.kedll.library.adapter.MultiTypeAdapter;
import com.kedll.library.base.KRefreshListActivity;
import com.kedll.library.dialog.ECAlertDialog;
import com.kedll.library.util.ToastUtil;

import net.sx.minemodule.R;
import net.sx.minemodule.databinding.MineActivityMineCollectBinding;
import net.sx.minemodule.mvp.bean.GoodCollectBean;
import net.sx.minemodule.mvp.item.GoodCollectItem;
import net.sx.minemodule.mvp.presenters.MineGoodCollectPresenter;

/**
 * 我的收藏
 * @author 11470
 */
@Route(path = ARouterPath.PATH_MINE_COLLECT)
public class MineCollectActivity extends KRefreshListActivity<MineActivityMineCollectBinding, MineGoodCollectPresenter> {

    @Override
    protected int getLayout() {
        return R.layout.mine_activity_mine_collect;
    }

    @Override
    protected void initToolBar(Bundle savedInstanceState) {
        super.initToolBar(savedInstanceState);
        setTitle("我的收藏");
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        adapter.setOnItemClickListener((MultiTypeAdapter.OnItemClickListener<GoodCollectBean>) (v, iItem) -> {
            ToastUtil.showToast("点击了");
        });
        adapter.setOnItemLongClickListener((MultiTypeAdapter.OnItemLongClickListener<GoodCollectBean>) (v, iItem) -> {
            ToastUtil.showToast("长按点击了");
            ECAlertDialog dialog = ECAlertDialog.buildAlert(v.getContext(), "确定删除?", (dialog1, which) -> {
                getPresenter().removeGoodsItem((GoodCollectItem) iItem);
            });
            dialog.show();
        });
    }

    @Override
    protected void initEvent() {
        super.initEvent();

    }

    @Override
    protected MineGoodCollectPresenter getPresenter() {
        return new MineGoodCollectPresenter(this);
    }
}
